﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Cfg;
using System.Web;
using NHibernate;
using ToolsLibrary;



namespace BusinessInterface
{
    public class NHibernateBaseConfig
    {
        public NHibernateBaseConfig()
        {
            string path = HttpContext.Current.Server.MapPath("~/hibernate.cfg.xml");
            DBConfiguration = new Configuration().Configure(path);
            DBConfiguration.Properties["connection.connection_string"] = SecurityDES.Decrypt(DBConfiguration.Properties["connection.connection_string"]);//"Data Source=.;Initial Catalog=EXSKYNET;Integrated Security=True;Pooling=False;uid=sa;pwd=kay1631";
            DBSession = DBConfiguration.BuildSessionFactory().OpenSession();
        }
        public Configuration DBConfiguration;
        public ISession DBSession;
        public void CloseSession()
        {
            if (DBSession.IsOpen)
            {
                DBSession.Close();
            }
        }
    }
}
